package com.shicijiaoliu.mapper;

import com.shicijiaoliu.pojo.Mainpost;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface Mainpostmapper {
    int getcount(String title, long aId, long sId);

    List<Mainpost> findBypage(String title, long aId, long sId);

    @Select("select * from mainpost where title=#{title}")
    Mainpost findBytitle(String title);


    @Delete("delete from mainpost where m_id=#{mId}")
    void delByid(long mId);

    @Select("select * from mainpost where m_id=#{mId}")
    Mainpost findByid(long mId);

    @Update("update mainpost set isjing=#{isjing} where m_id=#{mId}")
    void jiajing(long mId, String isjing);

    @Select("select * from mainpost")
    List<Mainpost> getlist();

    @Select("select * from mainpost where s_id=#{sid}")
    List<Mainpost> findBysid(long sid);

    @Update("update mainpost set a_id=#{aId},s_id=#{sId},finaltime=#{finaltime},clicks=#{clicks},postingtime=#{postingtime},content=#{content},title=#{title},replies=#{replies},isjing=#{isjing} where m_id=#{mId}")
    void update(Mainpost mpost);

    @Update("update mainpost set jubao=#{jubao} where m_id=#{mId}")
    void jubao(long mId, String jubao);

    @Insert("insert into mainpost (title,content, postingtime,finaltime, a_id, s_id,clicks,replies) " +
            " value (#{title},#{content},#{postingtime},#{finaltime},#{aId},#{sId},#{clicks},#{replies})")
    void add(Mainpost mpost);
}
